package com.ssm.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.github.pagehelper.PageInfo;
import com.ssm.base.BaseController;
import com.ssm.entity.UserInfo;
import com.ssm.service.UserInfoService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

/**
 * @Author jie_ge
 * @Date 2022/4/26
 */
@Controller
@RequestMapping("/userInfo")
public class UserInfoController extends BaseController {
    @Reference
    private UserInfoService userInfoService;

    @RequestMapping
    public String index(Map map, HttpServletRequest request){
        Map<String, Object> filters = getFilters(request);
        PageInfo<UserInfo> page = userInfoService.findPage(filters);
        map.put("page",page);
        map.put("filters",filters);
        return "userInfo/index";
    }

    @GetMapping("/lock/{id}/{status}")
    public String lock(@PathVariable("id") Long id,@PathVariable("status") Integer status){
        UserInfo userInfo = userInfoService.getById(id);
        userInfo.getStatus();
        userInfo.setStatus(status);
        userInfoService.update(userInfo);
        return "redirect:/userInfo";
    }

}
